package com.inei.formulariodedelitos2014.model.dao;

import java.util.List;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.inei.formulariodedelitos2014.model.connection.UtilBD;

public abstract class ACRUD<E> {

	SQLiteDatabase db;
	UtilBD util;
	Cursor c;
	ContentValues cv;

	public ACRUD(Context context) {
		util = new UtilBD(context);
	}
	
	public abstract List<E> leerTodo();
	public abstract List<E> leer(int id);
	public abstract E buscar(E o);
	public abstract int crear(E o);
	public abstract int actualizar(E o);
	public abstract int eliminar(E o);
	
	
	public void cerrar(){
		if(c!= null){
			c.close();
		}
		if(cv!=null){
			cv.clear();
		}
		if(db!=null){
			if(db.inTransaction()){
				db.endTransaction();
			}
			db.close();
		}
	}

}
